/**
 * Created by zheng on 2018/3/8.
 */


const teststore =  function(table, initialState = {}){
    this.table = table;
    this.state = {
      data: [],
      columns : [],
    }
    for (let props in initialState){
      if(this.state.hasOwnProperty(props)){
        this.state.props = initialState.props;
      }
    }

  }

teststore.prototype.mutations = {
  setData(state, data){
    state.data = data;
  },
  insertColumn(states, column, index){
    let array = states.columns;

    if(typeof index != 'undefined'){
      array.splice(index, 0, column);
    }else {
      array.push(column);
    }
  }
}


teststore.prototype.commit = function(instruct, ...args) {

  if (this.mutations[instruct])
    this.mutations[instruct].apply(this, [this.state].concat(args))
  else {
    console.log(`instruction not found: ${instruct}`)
  }
}


export default teststore;
